﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>测试接口</title>

    <link href="css/bootstrap.min.css" rel="stylesheet" />
    <script src="js/jquery-1.11.2.js"></script>
    <script src="js/m.js"></script>
    <script src="js/md5.min.js"></script>
</head>

<body>
    <div class="row">
        <a class="btn btndefault login">登陆</a>

        <a class="btn btndefault loginDv">不同设备登陆</a>

        <a class="btn btndefault exitLogin">退出</a>

        <a class="btn btndefault ordermain">获取用户数据</a>

        <a class="btn btndefault upword">修改密码</a>

        <a class="btn btndefault OrderMaster">获取订货会</a>
    </div>
    <script type="text/javascript">
        new Kmer({
            'AppRootPath': '',
            'CurrentUrl': ''
        });
        var a = Y.APIToken();
        //new window.Admin({});
        /**
         * 设置Cookie
         */
        var KmerSetCookie = Y.SetCookie;
        /**
         * 取Cookie
         * @param name cookie名称
         * @return string
         */
        var KmerGetCookie = Y.GetCookie;



        $('.login').click(function (e) {

            Y.API2("Login", "Login", {
                UserName: "wuweihua",
                PassWord: md5('1qaz2wsx'),
                DeviceId: md5("123456")
            }, function (data) {
                if (data.Success == false) {
                    alert(data.Message);
                } else {
                    UseAccessToken = data.AccessToken;
                    Y.UseUserToken = true;
                    sessionStorage.setItem("USER-ACCESS-TOKEN", UseAccessToken);
                    sessionStorage.setItem('login-info', JSON.stringify(data));
                }
            });
        });
        $('.loginDv').click(function (e) {

            Y.API2("Login", "Login", {
                UserName: "wuweihua",
                PassWord: md5('1qaz2wsx'),
                DeviceId: md5("123456789")
            }, function (data) {
                if (data.Success == false) {
                    alert(data.Message);
                } else {
                    UseAccessToken = data.AccessToken;
                    Y.UseUserToken = true;
                    sessionStorage.setItem("USER-ACCESS-TOKEN", UseAccessToken);
                    sessionStorage.setItem('login-info', JSON.stringify(data));
                }
            });
        });

        $('.OrderMaster').click(function () {
            Y.API2("TrialChooseVersionIPad", "GetOrderMaster", function (data) {
                if (data.Success == false) {
                    alert(data.Message);
                } else {
                    alert('获取成功');
                }
            });
        });

        $(".ordermain").click(function () {
            Y.API2("Users", "GetUserOrderMain", function (data) {
                if (data.Success == false) {
                    alert("什么鬼");
                } else {
                    //console.log(list);
                    alert(data);
                }
            })
            return false;
        });

        $(".upword").click(function () {
            Y.API2("Users", "SetPass", {
                "oldPass": md5('wf139250'),
                "newPass": md5('wf139250@'),
                "newPassRepeated": md5('wf139250@')
            }, function (data) {
                if (data.Success == false) {
                    alert(data.Message);
                } else {
                    //console.log(list);
                    alert(data);
                }
            })
            return false;
        })

        $('.exitLogin').click(function () {
            Y.API2("Login", "LoginOut", { DeviceId: md5("123456") }, function (data) {
                if (data.Success == false) {
                    alert(data.Message);
                } else {
                    Y.UseUserToken = false;
                    sessionStorage.removeItem("USER-ACCESS-TOKEN");
                    alert('退出成功');
                }
            });
        });


    </script>
</body>
</html>